<html xmlns:th="http://www.thymeleaf.org">
<form id="add_category_form" class="form-horizontal form-validate floating-label" role="form" novalidate="novalidate">
    <div class="card-body card-padding">
        <div class="form-group">
            <label for="categoryName" class="col-sm-3 control-label">接口分类名称</label>
            <div class="col-sm-9">
                <input type="text" name="categoryName" class="form-control input-sm" id="categoryName" placeholder="分类名称"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">状态</label>
            <div class="col-sm-9">
                <label class="radio radio-inline m-r-20">
                    <input type="radio" name="isValid" value="1" checked="checked"/>
                    <i class="input-helper"></i>
                    启用
                </label>
                <label class="radio radio-inline m-r-20">
                    <input type="radio" name="isValid" value="0"/>
                    <i class="input-helper"></i>
                    禁用
                </label>
            </div>
        </div>
        <div class="form-group">
            <label for="categoryDesc" class="col-sm-3 control-label">接口描述</label>
            <div class="col-sm-9">
                <textarea class="form-control" id="categoryDesc" name="categoryDesc" rows="3" placeholder="填写接口分类描述"></textarea>
            </div>
        </div>
        <input type="hidden" name="method" value="save"/>
        <input type="hidden" name="categoryId" value=""/>
    </div>
</form>
</html>
<script>
    $(function () {
        $('#add_category_form').bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                categoryName: {
                    validators: {
                        notEmpty: {
                            message: '分类名称不能为空'
                        }
                    }
                }
            }
        }).on('success.form.bv', function (e) {
            // Prevent submit form
//            e.preventDefault();

            $("#add_category_form").ajaxSubmit({
                type: "post",  //提交方式
                dataType: "json", //数据类型
                url: "/category/saveCategory",
                success: function (data) {
                    alert(data.reason);
                    if(data.ok){
                        $("#addInterfaceCategoryModelContent").html("");
                        $("#addInterfaceCategoryModel").modal("hide");
                        $("#data-table-interfaceCategory").bootgrid("reload");
                    }
                }
            })

        });
    })
</script>